define(["jquery", "easy-admin"], function ($, ea) {

var url = 'bot/text/index';
var add_url= 'bot/text/add';
if (typeof gfid !== 'undefined' && gfid !== '-1') {
    url = 'bot/text/index?filter=%7B%22botid%22%3A%22'+gfid+'%22%7D&op=%7B%22botid%22%3A%22%25*%25%22%7D';
    add_url = 'bot/text/add?id='+gfid;
}

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: url,
        add_url: add_url,
        edit_url: 'bot/text/edit',
        delete_url: 'bot/text/delete',
        export_url: 'bot/text/export',
        modify_url: 'bot/text/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:[
                    [{
                        text: '添加',
                        url: init.add_url,
                        method: 'open',
                        auth: 'add',
                        class: 'layui-btn layui-btn-normal layui-btn-sm',
                        icon: 'fa fa-plus ',
                        
                    }],
                    'refresh','delete','export'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'ID',search: false},
                    //{field: 'groupid', title: '群ID'},
                    //{field: 'botid', title: '机器人ID'},
                    {field: 'type', title: '类别',selectList: {1: '<a style="color:#1e9fff">模糊匹配</a>', 2: '<a style="color:#16b777">替换文字</a>',3:'<a style="color:#a233c6">撤回消息</a>'},search: false},
                    {field: 'gjz', title: '关键字',search: false},
                    {field: 'value', title: '回答',search: false},
                    {width: 250, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});